let url = {
  urlContent: `https://api.bilibili.com/x/v3/fav/resource/list?media_id=${this.mediaId}&pn=${this.pn}&ps=20&keyword=&order=mtime&type=0&tid=0&platform=web&jsonp=jsonp`,
  pn: 1,
  total: -1,
  mediaId: '159078549',
  getPrevPageUrl: function () {
    if (this.pn > 1) {
      this.pn--
    }
    return this.urlContent
  },
  getNexPageUrl: function () {
    if (this.hasNextPage()) {
      this.pn++;
    }
    return this.urlContent
  },
  hasNextPage: function () {
    return this.pn * 20 < this.total
  }
}

function mediaListAllItem (url) {
  const { net } = require('electron').remote
  let listResponse = ''
  const request = net.request(url.urlContent)
  let res = []
  request.on('response', (response) => {
    response.on('data', (r) => {
      listResponse += r
    })
    response.on('end', () => {
      let response = JSON.parse(listResponse)
      res.push(...response.data.medias)
      return res
    })
  })
  request.end()
}

export {url, mediaListAllItem}
